package section_17.compensatePotential;

import java.util.Collection;
import java.util.List;

public class Fill2Test {
	public static void main(String[] args) {

	}
}

interface Addable<T> {
	void add(T t);
}

class Fill2 {
	public static <T> void fill(Addable<T> addable, Class<? extends T> classToken, int size) {
		for (int i = 0; i < size; i++)
			try {
				addable.add(classToken.newInstance());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
	}
}

class AddableCollectionAdapter<T> implements Addable<T> {
	private Collection<T> c;

	public AddableCollectionAdapter(Collection<T> c) {
		this.c = c;
	}

	public void add(T item) {
		c.add(item);
	}
}

class Adapter {
	public static <T> Addable<T> collectioniAdapter(Collection<T> c) {
		return new AddableCollectionAdapter<T>(c);
	}
}

class AddableSimpleQueue<T> extends SimpleQueue<T> implements Addable<T> {
	public void add(T item) {
		super.add(item);
	}
}
